package com.usian.controller;

import com.usian.dtos.AdChannelDto;
import com.usian.pojo.AdChannel;
import com.usian.result.Result;
import com.usian.service.ChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/AdChannel")
@CrossOrigin
public class ChannelController {

    @Autowired
    private ChannelService channelService;

    @PostMapping("/findBySearch")
    public Result findBySearch(@RequestBody AdChannelDto adChannelDto){
        return channelService.findBySearch(adChannelDto);
    }

    @GetMapping("/findOne/{id}")
    public Result findOne(@PathVariable Integer id){
        return channelService.findOne(id);
    }

    @PostMapping("/save")
    public Result save(@RequestBody AdChannel adChannel){
        return channelService.save(adChannel);
    }

    @PutMapping("/update")
    public Result update(@RequestBody AdChannel adChannel){
        return channelService.save(adChannel);
    }

    @DeleteMapping("/deletes")
    public Result deletes(@RequestBody Integer[] ids){
        // 1. 循环单个删除
        // 2. sql  in （） id for删除  推荐使用这个方式
        return null;
    }
}
